package com.gr.dmbackend.service.Impl.dormaddmin;

import com.alibaba.fastjson.JSONObject;
import com.gr.dmbackend.mapper.RepairMapper;
import com.gr.dmbackend.model.Repair;
import com.gr.dmbackend.service.dormaddmin.HandleRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HandleRepairServiceImpl implements HandleRepairService {

    @Autowired
    private RepairMapper repairMapper;

    @Override
    public JSONObject handleRepair(int id) {

        JSONObject resp = new JSONObject();

        Repair repair = repairMapper.selectById(id);
        if (repair == null) {
            resp.put("error_message", "当前维修记录不存在");
            return resp;
        }

        repair.setRepairState("已处理");
        repairMapper.updateById(repair);
        resp.put("error_message", "success");

        return resp;
    }
}
